<template>
  <div class="app-container">
    <el-form :model="form" label-width="120px">
      <el-form-item label="Activity name">
        <el-input v-model="form.name" />
      </el-form-item>
      <el-form-item label="Activity zone">
        <el-select v-model="form.region" placeholder="please select your zone">
          <el-option label="Zone one" value="shanghai" />
          <el-option label="Zone two" value="beijing" />
        </el-select>
      </el-form-item>
      <el-form-item label="Activity time">
        <div style="display: flex;">
          <el-date-picker v-model="form.date1" type="date" placeholder="Pick a date" />
          <div class="line">-</div>
          <el-time-picker v-model="form.date2" type="fixed-time" placeholder="Pick a time" />
        </div>
      </el-form-item>
      <el-form-item label="Instant delivery">
        <el-switch v-model="form.delivery" />
      </el-form-item>
      <el-form-item label="Activity type">
        <el-checkbox-group v-model="form.type">
          <el-checkbox label="Online activities" name="type" />
          <el-checkbox label="Promotion activities" name="type" />
          <el-checkbox label="Offline activities" name="type" />
          <el-checkbox label="Simple brand exposure" name="type" />
        </el-checkbox-group>
      </el-form-item>
      <el-form-item label="Resources">
        <el-radio-group v-model="form.resource">
          <el-radio label="Sponsor" />
          <el-radio label="Venue" />
        </el-radio-group>
      </el-form-item>
      <el-form-item label="Activity form">
        <el-input v-model="form.desc" type="textarea" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">Create</el-button>
        <el-button @click="onCancel">Cancel</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script lang="ts">

import { ElMessage } from "element-plus"
import { defineComponent, ref } from "vue"

export default defineComponent({
  setup() {
    const form = ref({
      name: '',
      region: '',
      date1: '',
      date2: '',
      delivery: false,
      type: [],
      resource: '',
      desc: ''
    })
    function onSubmit() {
      ElMessage('submit!')
    }

    function onCancel() {
      ElMessage({
        message: 'cancel!',
        type: 'warning'
      })
    }

    return {
      form,
      onSubmit,
      onCancel
    }
  }
})
</script>

<style scoped>
.line {
  margin: 0 18px;
  text-align: center;
}
</style>

